home *** CD-ROM | disk | FTP | other *** search
- /*
- ** File: ExtendPrintRecord.c
- **
- ** Functions defined in Technote 1161
- **
- ** Copyright 1996-1999 Apple Computer. All rights reserved.
- **
- ** You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "DSC Sample Code"
- ** after having made changes. If you're going to re-distribute the source,
- ** we require that you make it clear in the source that the code was
- ** descended from Apple Sample Code, but that you've made changes.
- */
-
- #include <Printing.h>
- #include "ExtendPrintRecord.h"
-
- Boolean extendPrValidate(THPrint hPrint)
- /*
- The current driver is asked to extend the print record.
- If this fails, the print record handle is sized to the standard
- size print record (120 bytes).
- The current printer driver's PrValidate() routine is called to
- validate the print record whether it has been successfully
- extended or not.
- */
- {
- /*
- In case 'hPrint' is extended and the current printer driver doesn't
- support the extensible print record, we let extendPrintRecord()
- truncate the print record. The print record won't be truncated
- if the print record is already the standard size or if the current
- driver supports the extensible print record.
- */
- extendPrintRecord(hPrint);
-
- /* Call the real PrValidate with a correctly sized print record. */
- return PrValidate(hPrint);
- }
-
-
- void extendPrDefault(THPrint hPrint)
- {
- /*
- The default print record is the standard size for all drivers.
- So default the 120-byte record.
- */
- SetHandleSize((Handle)hPrint, sizeof(TPrint));
- PrintDefault(hPrint);
-
- /*
- Tell the printer driver it is okay to extend this print record.
- */
- extendPrintRecord(hPrint);
- }
-
-
- void extendPrintRecord(THPrint hPrint)
- {
- TExtendPrintRecord extend;
- /*
- Call the new PrGeneral opcode to see if the current printer driver
- supports extended print records. If the driver does support extended
- print records, it returns noErr. It marks the print record as
- extensible and may also extend it at this time.
- If the driver does not support extended print records,
- it returns 'OpNotImpl'.
- */
- extend.iOpCode = kExtendPrintRecordOp;
- extend.lReserved = 0;
- extend.hPrint = hPrint;
- PrGeneral((Ptr)&extend);
-
- /*
- If the driver fails to make the print record extensible,
- we make sure the print record is the standard 120 bytes.
- */
- if(extend.iError) SetHandleSize((Handle)hPrint, sizeof(TPrint));
- }
-